﻿@inject IStringLocalizer<Toasts> Localizer
@inject ToastService ToastService

<Button Icon="fa-solid fa-circle-exclamation" OnClick="@OnShowHeaderClick" Text="@Localizer["ShowHeaderText"]"></Button>

@code {
    [CascadingParameter]
    [NotNull]
    private BootstrapBlazorRoot? Root { get; set; }

    [NotNull]
    private ToastContainer? ToastContainer { get; set; }

    /// <summary>
    /// OnInitialized
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        ToastContainer = Root.ToastContainer;
    }

    private async Task OnShowHeaderClick()
    {
        ToastContainer.SetPlacement(Placement.BottomEnd);
        await ToastService.Show(new ToastOption()
        {
            Category = ToastCategory.Warning,
            ShowHeader = false,
            Content = "The system adds new components, it will automatically shut down after 4 seconds"
        });
    }
}
